/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thinkinginjava.svn.typeinformation;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author public_enemy
 */
interface HasBatteries {
}

interface Waterproof {
}

interface Shoots {
}

interface Run {
}

class Toy {

    public Toy() {
    }

    Toy(int i) {
    }
}

class FancyToy extends Toy implements HasBatteries, Waterproof, Shoots, Run {

    public FancyToy() {
        super(1);
    }
}

public class ToyTest {

    public static void printInfo(Class cc) {
        System.out.println("Class name: " + cc.getName() + " is interace?" + "[" + cc.isInterface() + "] ");
        System.out.println("Simple name: " + cc.getSimpleName());
        System.out.println("Canonical name: " + cc.getCanonicalName());
    }

    public static void main(String[] args) {
        Class c = null;
        try {
            c = Class.forName("thinkinginjava.svn.typeinformation.FancyToy");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ToyTest.class.getName()).log(Level.SEVERE, null, ex);
            System.exit(1);
        }
        printInfo(c);
        for (Class face : c.getInterfaces()) {
            printInfo(face);
        }

        Class up = c.getSuperclass();
        Object obj = null;
        try {
            obj = up.newInstance();
            
            if (obj instanceof Object) {
                System.out.println("Object is a Toy");
            }
        } catch (InstantiationException ex) {
            Logger.getLogger(ToyTest.class.getName()).log(Level.SEVERE, null, ex);
            System.exit(1);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(ToyTest.class.getName()).log(Level.SEVERE, null, ex);
            System.exit(1);
        }
        printInfo(obj.getClass());
    }
}
